package cn.jdy.plugins.wap;

import java.io.File;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import javax.print.Doc;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import cn.jdy.authority.entity.User;
import cn.jdy.common.constant.GlobalConstant;
import cn.jdy.common.ctrl.BaseCtrl;
import cn.jdy.common.util.ScoreRuleUtil;
import cn.jdy.framework.exception.BaseException;
import cn.jdy.framework.log.BaseLog;
import cn.jdy.framework.safe.SafeUtil;
 
import cn.jdy.framework.util.DateUtil;
import cn.jdy.framework.util.StringUtil;
import cn.jdy.platform.entity.ConfValue;
import cn.jdy.platform.service.ConfService;
 
import cn.jdy.plugins.entity.ApplyCash;
import cn.jdy.plugins.entity.CRateOrder;
import cn.jdy.plugins.entity.Info;
 
import cn.jdy.plugins.entity.Maid;
import cn.jdy.plugins.entity.Member;
import cn.jdy.plugins.entity.MemberCard;
import cn.jdy.plugins.entity.Productx;
import cn.jdy.plugins.service.ApplyCashService;
import cn.jdy.plugins.service.CRateOrderService;
import cn.jdy.plugins.service.InfoService;
import cn.jdy.plugins.service.MaidService;
import cn.jdy.plugins.service.MemberCardService;
import cn.jdy.plugins.service.MemberService;
import cn.jdy.plugins.service.PointRecordService;
import cn.jdy.plugins.service.ProductxService;

/**
 * 我的个人
 *
 * @author zhaigt
 */
@Controller
@RequestMapping("/member")
public class MemberCtrl extends BaseCtrl {
	@Autowired
	private CRateOrderService cRateOrderService;
 
	@Autowired
	private MaidService maidService;
	@Autowired
	private ConfService confService;
 
	@Autowired
	private InfoService infoService;

	@Autowired
	private ProductxService productxService;
	@Autowired
	private MemberService memberService;
	@Autowired
	private PointRecordService pointRecordService;
	@Autowired
	private ApplyCashService applyCashService;
	@Autowired
	private MemberCardService memberCardService;

	
	/**
	 * 会员 个人中心 首页
	 *
	 * @author: wuzhiliang
	 * @date: 2013-10-15 16:53
	 */
	@RequestMapping("")
	public ModelAndView index(CRateOrder order) {
		ModelAndView mv = new ModelAndView("/member/member.jsp");

		try {
			//  CRateOrder
			// 用户信息 手机号中间替换为*
			Member member = super.getMember(true);
		//	CRateOrder  cRateOrder = cRateOrderService.find("memberid",member.getId()).get(0);
			//	mv.addObject("cRateOrder", cRateOrder);
		//	mv.addObject("pro", productxService.find(cRateOrder.getProductxid()));
		//	sss
			   SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
		       
			    Calendar calendar = Calendar.getInstance();
		        calendar.setTime(new Date());
		        calendar.add(Calendar.DAY_OF_MONTH, -1);//+1今天的时间加一天
		        
				mv.addObject("fs", 	memberService.findcheckcount(member.getId()));

			mv.addObject("zjjf", 	memberService.getzuojifen(df.format(calendar.getTime()),member.getId()));
			mv.addObject("member", memberService.find(member.getId()));
			mv.addObject("lej", 	memberService.getliejijifen(member.getId()));
			mv.addObject("jztg", 	memberService.getjtgjl(member.getId()));//今日推广奖励



		} catch(Exception e) {
			mv.addObject("msg", "error");
			BaseLog.e(this.getClass(), "updResetPwd:会员 资料管理有误", e);
		}
		return mv;
	}
	
	/**
	 *去提现
	 *
	 * @author: jga
	 * @date: 2018-10-15 16:53
	 */
	@RequestMapping("toTmoeryme")
	public ModelAndView toTmoeryme(CRateOrder order) {
		ModelAndView mv = new ModelAndView("/member/changetxCard.jsp");

		try {
 
			Member member = super.getMember(true);
			mv.addObject("member", memberService.find(member.getId()));


		} catch(Exception e) {
			mv.addObject("msg", "error");
			BaseLog.e(this.getClass(), "updResetPwd:会员 资料管理有误", e);
		}
		return mv;
	}
	
	/**
	 * 会员 设置
	 *
	 * @author: wuzhiliang
	 * @date: 2013-10-15 16:53
	 */
	@RequestMapping("/indexsz")
	public ModelAndView indexsz(CRateOrder order) {
		ModelAndView mv = new ModelAndView("/member/mysetting.jsp");
		try {
			Member member = super.getMember(true);
			mv.addObject("member", memberService.find(member.getId()));
		} catch(Exception e) {
			mv.addObject("msg", "error");
			BaseLog.e(this.getClass(), "updResetPwd:会员 资料管理有误", e);
		}
		return mv;
	}
	
	/**
	 * 查看分佣记录
	 *
	 * @author: wuzhiliang
	 * @date: 2018-10-15 16:53
	 */
	@RequestMapping("/openmingxi")
	public ModelAndView openmingxi( ) {
		ModelAndView mv = new ModelAndView("/member/moneylist.jsp");
		try {
			Member member = super.getMember(true);
			mv.addObject("maidlist", maidService.find("wermemberid",member.getId()));
		} catch(Exception e) {
			mv.addObject("msg", "error");
			BaseLog.e(this.getClass(), "有误", e);
		}
		return mv;
	}

	/**
	 * 查看自己全部的粉丝
	 *
	 * @author: jga
	 * @date: 2018-10-15 16:53
	 */
	@RequestMapping("/openallfans")
	public ModelAndView openallfans( ) {
		ModelAndView mv = new ModelAndView("/member/myallfans.jsp");
		try {
			Member member = super.getMember(true);
			
			//mv.addObject("alllist", memberService.find("tuandui",member.getId()));//全部

			mv.addObject("alllist", memberService.queryshangjin(member.getId()));
		} catch(Exception e) {
			mv.addObject("msg", "error");
			BaseLog.e(this.getClass(), "有误", e);
		}
		return mv;
	}
	/**
	 * 查看自己直推的粉丝
	 *
	 * @author: jga
	 * @date: 2018-10-15 16:53
	 */
	@RequestMapping("/openzfans")
	public ModelAndView openzfans( ) {
		ModelAndView mv = new ModelAndView("/member/myfans.jsp");
		try {
			Member member = super.getMember(true);

			mv.addObject("zlist", memberService.find("fid",member.getId()));//直推
	
 
		} catch(Exception e) {
			mv.addObject("msg", "error");
			BaseLog.e(this.getClass(), "有误", e);
		}
		return mv;
	}
	/**
	 * 个人中心的菜单列表配置
	 * @return
	 */
	private List<ConfValue> getMenus() {
    String path = request.getContextPath();
    List<ConfValue> menus = new LinkedList<ConfValue>();

    ConfValue cv0 = new ConfValue();
    cv0.setValue0("我的消息");
    cv0.setValue1(path+"/member/myinfo");
    cv0.setValue2("/static/img/myxx.png");
    cv0.setRemark("#d87570");

    ConfValue cv1 = new ConfValue();
    cv1.setValue0("我的收藏");
    cv1.setValue1(path+"/member/mycollect");
    cv1.setValue2("/static/img/mysc.png");
    cv1.setRemark("#d87570");

    ConfValue cv2 = new ConfValue();
    cv2.setValue0("我的下载");
    cv2.setValue1(path+"/member/myorders");
    cv2.setValue2("/static/img/myorder.png");
    cv2.setRemark("#118adb");

    ConfValue cv3 = new ConfValue();
    cv3.setValue0("上传文章");
    cv3.setValue1(path+"/member/mydoc");
    cv3.setValue2("/static/img/mywz.png");
    cv3.setRemark("#58d2f0");

    ConfValue cv4 = new ConfValue();
    cv4.setValue0("下载文章");
    cv4.setValue1(path+"/member/mydown");
    cv4.setValue2("/static/img/mydwon.png");
    cv4.setRemark("#febf02");

    ConfValue cv5 = new ConfValue();
    cv5.setValue0("我的贡献");
    cv5.setValue1(path+"/member/mygongxian");
    cv5.setValue2("/static/img/mygx.png");
    cv5.setRemark("#bc4040");

    ConfValue cv6 = new ConfValue();
    cv6.setValue0("上传信息");
    cv6.setValue1(path+"/business/initHeJameng");
    cv6.setValue2("/static/img/myup.png");
    cv6.setRemark("#ff8b00");

    ConfValue cv8 = new ConfValue();
    cv8.setValue0("修改密码");
    cv8.setValue1(path+"/member/updatePwd");
    cv8.setValue2("/static/img/mypwd.png");
    cv8.setRemark("#58d2f0");

    menus.add(cv0);
    menus.add(cv1);
    menus.add(cv3);
    menus.add(cv4);
    menus.add(cv2);
    menus.add(cv5);
    menus.add(cv6);
    menus.add(cv8);
    return menus;
  }

	@RequestMapping("/{forward}")
	public ModelAndView updatePwd(@PathVariable("forward")  String forward){
		ModelAndView mv = new ModelAndView(super.t + "/member/"+forward);
		Member member = super.getMember(true);
		mv.addObject("member", member);
		return mv;
	}

	/**
	 * 会员管理手机号重置
	 *
	 * @param mobile
	 * @param userid
	 * @return
	 */
	@RequestMapping("/forUpdateMobile")
	public ModelAndView forUpdateMobile(String mobile, String userid) {
		ModelAndView mv = new ModelAndView(super.t + "/login");
		try {
			Member mbo = new Member();
			mbo.setMobile(mobile);
			mbo.setId(userid);
			memberService.updateMobile(mbo);

			Member memberBo = (Member) super.getMember();
			memberBo.setMobile(mobile);
			
			// 密码修改成功 跳转到 登录页面并提示
      mv.addObject("msg", "密码修改成功!");//
		} catch(BaseException e) {
			mv.addObject("msg", "error");
			BaseLog.e(this.getClass(), "updResetPwd:会员管理手机号重置有误", e);
		}
		return mv;
	}

	/**
	 * 会员管理用手机号重置密码
	 *
	 * @return
	 */
	@RequestMapping("/forUpdatePwd")
	public ModelAndView forUpdatePwd(String password) {
		ModelAndView mv = new ModelAndView("redirect:/login?errorType=10");
		try {
			Member mbo = new Member();
			Member memberBo = super.getMember();
			mbo.setId(memberBo.getId());
			mbo.setPassword(SafeUtil.md5(password).substring(8, 16));
			memberService.updResetPwd(mbo);
			session.invalidate();
		} catch(BaseException e) {
			BaseLog.e(this.getClass(), "updResetPwd:密码修改有误", e);
		}
		return mv;
	}


	

	
	/**
   * 我的消息信息
   *
   * @param bo
   * @param pageSize
   * @return
   */
  @RequestMapping("/myinfo")
  public ModelAndView forMyMessage(Info bo, Integer pageSize,String searchtype) {
    ModelAndView mv = new ModelAndView(super.t+"/member/myinfo");
    return mv;
  }
  
  /**
   * 我的消息信息
   *
   * @param bo
   * @param pageSize
   * @return
   */
  @RequestMapping("/myinfoLoadMore")
  @ResponseBody
  public Map<String, Object> myinfoLoadMore(Info bo, Integer pageSize,String searchtype) {
      Map<String, Object> resp = new HashMap<>();
      
    bo.setUserid(super.getMember().getId());
    if(!"-1".equals(searchtype)){// -1 全部
      bo.setFlag(searchtype);
    }
    try {
      /************* 分页处理开始 ************/
      String Count = infoService.getInfoCount(bo);//查询我的消息信息总条数
      Map<String, Integer> map = getPageInfo(bo.getPageNo(), pageSize, Count);//获取page信息
      bo.setPageNo(map.get("currentPage"));
      pageSize = map.get("pageSize");
      /************* 分页处理结束 ***********/

      bo.setPagestart((bo.getPageNo() - 1) * pageSize);//查询起始值
      bo.setPagesize(pageSize);//查询条数
      List<Info> list = infoService.query(bo);

      for(Info info:list){
        if(info.getType().equals("4")){//前台用户
          Member member = memberService.find(info.getSendUserId());
          if(member!=null)
            info.setSendUsername(member.getUserName());
        }else if(info.getType().equals("2")){
//          User user =  userManage.findOne("id", info.getSendUserId());
//          if(user!=null)
//            info.setSendUsername(user.getUsername());
        }else{
          info.setSendUsername("system");
        }
      }

        if(list!=null && list.size()>0) {
            resp.put("dataList", list);
            resp.put("statusCode", 200);
        }else {
            resp.put("statusCode", 400);
        }
//      mv.addObject("menberBo", (Member) super.getMember());
    } catch(Exception e) {
      BaseLog.e(this.getClass(), "查询我的消息信息错误", e);
    }
    return resp;
  }

  /**
   * 根据id 查看消息信息
   * @param id
   * @return
   */
  @RequestMapping("/myinfo/{id}")
  public ModelAndView findInfoById(@PathVariable String id){
      ModelAndView mv = new ModelAndView(super.t + "/member/myinfoDetail");
      try{
          if(null!=id && !"".equals(id)){
              Info info = infoService.find(id);
              mv.addObject("infobo",info);
              if(info!=null){
                  info.setFlag("1");
                  infoService.update(info);
              }
          }
      }catch (Exception e){
          BaseLog.e(this.getClass(),"查找消息失败！",e);
      }
      return mv;
  }
  
 
   

  /**
   * 我的订单
   */
  @RequestMapping("/myorders")
  public ModelAndView queryOrders(CRateOrder order, String fromDate, String toDate) {
    ModelAndView mv = new ModelAndView(super.t + "/member/myorders");
    return mv;
  }
  /**
   * 我的订单
   */
  @RequestMapping("/myordersLoadMore")
  @ResponseBody
  public Map<String, Object> myordersLoadMore(CRateOrder order, int pageNo, int pageSize) {
  	Map<String, Object> jsonMap = new HashMap<String, Object>();

    try {
      //设置分页信息
    /*  if(order.getiDisplayLength() == 0) order.setiDisplayLength(5);                //默认长度5
      if(order.getPageNo()<=0) order.setPageNo(1);                                  //默认页数1
      order.setiDisplayStart((order.getPageNo() - 1) * order.getiDisplayLength());  //显示起始索引
      order.setMemberid(getMember(false).getId());*/
      
		Long count = 0L;
		List<CRateOrder> list = new ArrayList<CRateOrder>();
		DetachedCriteria dc = DetachedCriteria.forClass(CRateOrder.class);
   	 Member mbo1 =(Member) session.getAttribute("user");

		if (!StringUtil.isNullOrEmpty(mbo1.getId())) {
			dc.add(Restrictions.eq("memberid", mbo1.getId()));
		}
		dc.add(Restrictions.eq("zfStatus", "1"));

		dc.addOrder(Order.asc("createTime"));
		list = cRateOrderService.find(dc,pageNo, pageNo+pageSize);
		count = cRateOrderService.count(dc);
		jsonMap.put("datalist", list);
		jsonMap.put("iTotalDisplayRecords", count);
		
    }catch (Exception e){
    	jsonMap.put("msg", "500");
	
        BaseLog.e(this.getClass(),"查找消息失败！",e);
    }
	return jsonMap;
  }

	 

	
	@RequestMapping("/checkPwd")
	@ResponseBody
	public Map<String, Object> checkPwd(String param) {
		Map<String, Object> jsonMap = new HashMap<String, Object>();
		Member member = super.getMember();
		if(param!=null && member!=null && SafeUtil.md5(param).substring(8, 16).equals(member.getPassword())) {
			jsonMap.put("status", "y");
		} else {
			jsonMap.put("status", "n");
			jsonMap.put("info", "原密码错误");
		}
		return jsonMap;
	}
	
	/**
	 * 确认转租
	 * @param param
	 * @return
	 */
	
	@RequestMapping("/checkzhuanz")
	@ResponseBody
	public Map<String, Object> checkzhuanz(CRateOrder order) {
		Map<String, Object> jsonMap = new HashMap<String, Object>();
		Member member = super.getMember();
		CRateOrder  ce=cRateOrderService.find(order.getId());
		ce.setSendStatus("4");
		ce.setCztime(DateUtil.getCurrentDate(DateUtil._DEFAULT2));
		
		try {
	
			Member	members  =memberService.find(ce.getMemberid());
		
			if(ce.getIstqsr().equals("0")){
		
						if(memberCardService.count("memberid",members.getId())>0){
							cRateOrderService.update(ce);
							Member	memberf =memberService.findOne("fid",members.getId());
					  		Maid  ma=new Maid();
					  		ma.setOrderNo(ce.getOrderNo());
					  		ma.setUsername(member.getUserName());
					  		ma.setMch_id(ce.getMch_id());
					  		ma.setMemberid(ce.getMemberid());
					  		ma.setProductxid(ce.getProductxid());
					  		ma.setProductxname(ce.getProductxname());
					  		ma.setCreateTime(DateUtil.getCurrentDate(DateUtil._DEFAULT2));
					  		ma.setTotal(ce.getTotal());
					  		ma.setFs(ce.getFs());
					  		if(memberf!=null){
					  	  		ma.setWermemberid(members.getId());
						  		ma.setWerusername(members.getUserName());
						  		 
						  		//计算分多少佣金
						  		double zyj=0;
						  		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
						  		
							  	int sj=1;
								try {
									sj = redays(ce.getCreateTime(), df.format(new Date()))-1;
								} catch (Throwable e) {
									// TODO Auto-generated catch block
									e.printStackTrace();
								}
								ConfValue cf= confService.queryByType(10, 0L).get(0);
								double lvs=Double.valueOf(cf.getValue0());
								System.out.println("kan----"+lvs);
						  		zyj=ce.getTotal()*lvs/365*sj;
						  		ma.setIsfa("0");
						  		ma.setFendtotal(zyj);
						  		maidService.save(ma);
								jsonMap.put("info", "修改成功！");
								jsonMap.put("statusCode", 200);
						}
			  	
		  		}else{
					jsonMap.put("info", "请先添加银行卡");
					jsonMap.put("statusCode", 500);
				}
		
		
			}else{
				
				
				String dqtime=ce.getDqtime()+"";///到期时间
	     		SimpleDateFormat s=new SimpleDateFormat("yyyy-MM-dd");
	     		Calendar calendar = Calendar.getInstance();
	     		Date dqs=   s.parse(dqtime); //到期时间
	     		calendar.setTime(dqs);
	     		calendar.add(Calendar.DATE, -1);//到期时间减一天在相比
	        	calendar.getTime();
	        	Date jytdq=  calendar.getTime();
	        	Date dq= new Date(); //当前时间
	 
				 if(dq.getTime()>=jytdq.getTime()){
						cRateOrderService.update(ce);
						Member	memberf =memberService.findOne("fid",members.getId());
				  		Maid  ma=new Maid();
				  		ma.setOrderNo(ce.getOrderNo());
				  		ma.setUsername(member.getUserName());
				  		ma.setMch_id(ce.getMch_id());
				  		ma.setMemberid(ce.getMemberid());
				  		ma.setProductxid(ce.getProductxid());
				  		ma.setProductxname(ce.getProductxname());
				  		ma.setCreateTime(DateUtil.getCurrentDate(DateUtil._DEFAULT2));
				  		ma.setTotal(ce.getTotal());
				  		ma.setFs(ce.getFs());
				  		if(memberf!=null){
				  	  		ma.setWermemberid(members.getId());
					  		ma.setWerusername(members.getUserName());
					  		 
					  		//计算分多少佣金
					  		double zyj=0;
					  		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
					  		
						  	int sj=1;
							try {
								sj = redays(ce.getCreateTime(), df.format(new Date()))-1;
							} catch (Throwable e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
							}
							ConfValue cf= confService.queryByType(10, 0L).get(0);
							double lvs=Double.valueOf(cf.getValue0());
							System.out.println("kan----"+lvs);
					  		zyj=ce.getTotal()*lvs/365*sj;
					  		ma.setIsfa("0");
					  		ma.setFendtotal(zyj);
					  		maidService.save(ma);
							jsonMap.put("info", "修改成功！");
							jsonMap.put("statusCode", 200);
				 }
			}else{
				jsonMap.put("info", "未到期！");
				jsonMap.put("statusCode", 500);
			}
			
			 }
		 
		} catch(Exception e) {
			BaseLog.e(getClass(), "修改资料异常", e);
			jsonMap.put("info", "系统异常！");
			jsonMap.put("statusCode", 500);
		}
		return jsonMap;
	}

	public static int redays(String k,String j) throws Throwable{
		SimpleDateFormat simpleFormat = new SimpleDateFormat("yyyy-MM-dd");//如2016-08-10 20:40
		String fromDate = k;
		String toDate = j;
		long from = simpleFormat.parse(fromDate).getTime();
		long to = simpleFormat.parse(toDate).getTime();
		int days = (int) ((to - from)/(1000 * 60 * 60 * 24));
			return days;
	}

	/**
	 * wap会员个人中心
	 * @param mb
	 * @return
	 */
	@RequestMapping("/vipCenter")
	public ModelAndView vip4wap(Member user){
		ModelAndView mv = new ModelAndView("/my/my.jsp");
		return mv;
	}
	

	/**
	 * 去修改密码 
	 * @param mb
	 * @return
	 */
	@RequestMapping("/toupdataps")
	public ModelAndView toupdataps(Member user){
		ModelAndView mv = new ModelAndView("/member/changepwd.jsp");
		return mv;
	}
	
	/**
	 * 修改密码 
	 *
	 * @param user
	 * @param passwdNew
	 * @return
	 */
	@RequestMapping("/selfsave")
	@ResponseBody
	public Map<String, Object> selfsave(Member user, String passwdNew) {
		Map<String, Object> jsonMap = new HashMap<String, Object>();
		Member userOld = (Member) session.getAttribute("user");
		try {
			if(userOld != null && userOld.getPassword().equals(SafeUtil.md5(user.getPassword()).substring(8, 16))) {
				// 只修改密码字段111
				userOld=	memberService.find(userOld.getId());
				userOld.setPassword( SafeUtil.md5(passwdNew).substring(8, 16));
				memberService.update(userOld);
				jsonMap.put("info", "修改成功！");
				jsonMap.put("statusCode", 200);
			} else {
				jsonMap.put("info", "原密码输入错误！");
				jsonMap.put("statusCode", 500);
			}
		} catch(Exception e) {
			BaseLog.e(getClass(), "用户修改资料异常", e);
			jsonMap.put("info", "系统异常！");
			jsonMap.put("statusCode", 500);
		}

		return jsonMap;
	}
	
	/**
	 * wap会员个人资料
	 * @param user
	 * @return
	 */
	@RequestMapping("/personalInfo")
	public ModelAndView pinfo4wap(Member user){
		ModelAndView mv = new ModelAndView("/my/myInfo.jsp");
		return mv;
	}
	

	/**
	 * 提现
	 *
	 * @param user
	 * @param passwdNew
	 * @return
	 */
	@RequestMapping("/jianjifen")
	@ResponseBody
	public Map<String, Object> jianjifen(Member user, String passwdNew,double myoney) {
		Map<String, Object> jsonMap = new HashMap<String, Object>();
		Member userOld = (Member) session.getAttribute("user");
		try {
			if(userOld != null ) {
				// 只修改密码字段111
				Member	dw=	memberService.find(userOld.getId());

				if(StringUtil.isNotEmpty(dw.getTxpassd())&&dw.getTxpassd().equals(passwdNew)){
				//新增一条提现记录
				ApplyCash cash = new ApplyCash();
				cash.setUserOpenId(userOld.getId());
				cash.setUserNickName(userOld.getNickName());
				cash.setStatus("1");   //1-申请提现 ，2-成功， 3-失败
				cash.setApplyCash(myoney*0.9);
				cash.setYgapplyCash(myoney);
				
				cash.setCreateTime(DateUtil.getCurrentDate(DateUtil._DEFAULT2));
				cash.setTotal(0);
			
				List<MemberCard> list2=	memberCardService.find("memberid",userOld.getId());
				List<ApplyCash> list=	applyCashService.find("userOpenId",userOld.getId(),"status","1");
				if(list2.size()>0){
					if(list.size()<=0){
						MemberCard  mc=list2.get(0);
						cash.setCardname(mc.getCardname());
						cash.setCardnumber(mc.getCardnumber());
						cash.setSmh(mc.getSmh());
						applyCashService.save(cash);
						jsonMap.put("info", "成功！");
						jsonMap.put("statusCode", 200);
						userOld=	memberService.find(userOld.getId());
						userOld.setMoney(0);
						memberService.update(userOld);
						}else{
						jsonMap.put("info", "你还有一笔提现正在处理，请稍后");
						jsonMap.put("statusCode", 500);
						
					}
				}else{
					jsonMap.put("info", "请绑定银行卡，请稍后");
					jsonMap.put("statusCode", 500);
				}
   			}else{
   				jsonMap.put("info", "你未设置密码或者提现密码不对");
				jsonMap.put("statusCode", 500);
   			}
			}
			
		} catch(Exception e) {
			BaseLog.e(getClass(), "用户修改资料异常", e);
			jsonMap.put("info", "系统异常！");
			jsonMap.put("statusCode", 500);
		}

		return jsonMap;
	}

}
